home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / object.h < prev    next >
Text File  |  1993-05-11  |  8KB  |  298 lines

  1. /*
  2.  * FIG : Facility for Interactive Generation of figures
  3.  * Copyright (c) 1985 by Supoj Sutanthavibul
  4.  *
  5.  * "Permission to use, copy, modify, distribute, and sell this software and its
  6.  * documentation for any purpose is hereby granted without fee, provided that
  7.  * the above copyright notice appear in all copies and that both that
  8.  * copyright notice and this permission notice appear in supporting
  9.  * documentation, and that the name of M.I.T. not be used in advertising or
  10.  * publicity pertaining to distribution of the software without specific,
  11.  * written prior permission.  M.I.T. makes no representations about the
  12.  * suitability of this software for any purpose.  It is provided "as is"
  13.  * without express or implied warranty."
  14.  *
  15.  */
  16.  
  17. #define        DEFAULT              (-1)
  18. #define        SOLID_LINE        0
  19. #define        DASH_LINE        1
  20. #define        DOTTED_LINE        2
  21. #define        RUBBER_LINE        3
  22. /* #define        PANEL_LINE        4  ** not needed for gnuplot */
  23.  
  24. #define        Color            long
  25.  
  26. #define        BLACK            0
  27. #define        WHITE            7
  28.  
  29. typedef struct f_pattern {
  30.     int            w, h;
  31.     int           *p;
  32. }
  33.         F_pattern;
  34.  
  35. typedef struct f_point {
  36.     int            x, y;
  37.     struct f_point *next;
  38. }
  39.         F_point;
  40.  
  41. typedef struct f_pos {
  42.     int            x, y;
  43. }
  44.         F_pos;
  45.  
  46. typedef struct f_arrow {
  47.     int            type;
  48.     int            style;
  49.     float        thickness;
  50.     float        wid;
  51.     float        ht;
  52. }
  53.         F_arrow;
  54.  
  55. typedef struct f_ellipse {
  56.     int            tagged;
  57.     int            type;
  58. #define                    T_ELLIPSE_BY_RAD    1
  59. #define                    T_ELLIPSE_BY_DIA    2
  60. #define                    T_CIRCLE_BY_RAD        3
  61. #define                    T_CIRCLE_BY_DIA        4
  62.     int            style;
  63.     int            thickness;
  64.     Color        color;
  65.     int            depth;
  66.     int            direction;
  67.     float        style_val;
  68.     float        angle;
  69.     int            pen;
  70.     int            fill_style;
  71. #define                    UNFILLED    0
  72. #define                    WHITE_FILL    1
  73. #define                    BLACK_FILL    21
  74.     struct f_pos    center;
  75.     struct f_pos    radiuses;
  76.     struct f_pos    start;
  77.     struct f_pos    end;
  78.     struct f_ellipse *next;
  79. }
  80.         F_ellipse;
  81.  
  82. typedef struct f_arc {
  83.     int            tagged;
  84.     int            type;
  85. #define                    T_3_POINTS_ARC        1
  86.     int            style;
  87.     int            thickness;
  88.     Color        color;
  89.     int            depth;
  90.     int            pen;
  91.     int            fill_style;
  92.     float        style_val;
  93.     int            direction;
  94.     struct f_arrow *for_arrow;
  95.     struct f_arrow *back_arrow;
  96.     struct {
  97.     float        x, y;
  98.     }            center;
  99.     struct f_pos    point[3];
  100.     struct f_arc   *next;
  101. }
  102.         F_arc;
  103.  
  104. #define        CLOSED_PATH        0
  105. #define        OPEN_PATH        1
  106. #define        DEF_BOXRADIUS        7
  107. #define        DEF_DASHLENGTH        4
  108. #define        DEF_DOTGAP        3
  109.  
  110. typedef struct f_line {
  111.     int            tagged;
  112.     int            type;
  113. #define                    T_POLYLINE    1
  114. #define                    T_BOX        2
  115. #define                    T_POLYGON    3
  116. #define                    T_ARC_BOX    4
  117. #define                    T_EPS_BOX    5
  118.     int            style;
  119.     int            thickness;
  120.     Color        color;
  121.     int            depth;
  122.     float        style_val;
  123.     int            pen;
  124.     int            fill_style;
  125.     int            radius;    /* corner radius for T_ARC_BOX */
  126.     struct f_arrow *for_arrow;
  127.     struct f_arrow *back_arrow;
  128.     struct f_point *points;
  129.     struct f_eps   *eps;
  130.     struct f_line  *next;
  131. }
  132.         F_line;
  133.  
  134. typedef struct f_text {
  135.     int            tagged;
  136.     int            type;
  137. #define                    T_LEFT_JUSTIFIED    0
  138. #define                    T_CENTER_JUSTIFIED    1
  139. #define                    T_RIGHT_JUSTIFIED    2
  140.     int            font;
  141.     int            size;    /* point size */
  142.     Color        color;
  143.     int            depth;
  144.     float        angle;    /* in radian */
  145.  
  146.     int            flags;
  147. #define                    RIGID_TEXT        1
  148. #define                    SPECIAL_TEXT        2
  149. #define                    PSFONT_TEXT        4
  150. #define                    HIDDEN_TEXT        8
  151.  
  152.     int            height;    /* pixels */
  153.     int            length;    /* pixels */
  154.     int            base_x;
  155.     int            base_y;
  156.     int            pen;
  157.     char       *cstring;
  158.     struct f_text  *next;
  159. }
  160.         F_text;
  161.  
  162. #define MAXFONT(T) (psfont_text(T) ? NUM_PS_FONTS : NUM_LATEX_FONTS)
  163.  
  164. #define        rigid_text(t) \
  165.             (t->flags == DEFAULT \
  166.                 || (t->flags & RIGID_TEXT))
  167.  
  168. #define        special_text(t) \
  169.             ((t->flags != DEFAULT \
  170.                 && (t->flags & SPECIAL_TEXT)))
  171.  
  172. #define        psfont_text(t) \
  173.             (t->flags != DEFAULT \
  174.                 && (t->flags & PSFONT_TEXT))
  175.  
  176. #define        hidden_text(t) \
  177.             (t->flags != DEFAULT \
  178.                 && (t->flags & HIDDEN_TEXT))
  179.  
  180. #define        text_length(t) \
  181.             (hidden_text(t) ? hidden_text_length : t->length)
  182.  
  183. #define        using_ps    (cur_textflags & PSFONT_TEXT)
  184.  
  185. typedef struct f_control {
  186.     float        lx, ly, rx, ry;
  187.     struct f_control *next;
  188. }
  189.         F_control;
  190.  
  191. #define        int_spline(s)        (s->type & 0x2)
  192. #define        normal_spline(s)    (!(s->type & 0x2))
  193. #define        closed_spline(s)    (s->type & 0x1)
  194. #define        open_spline(s)        (!(s->type & 0x1))
  195.  
  196. typedef struct f_spline {
  197.     int            tagged;
  198.     int            type;
  199. #define                    T_OPEN_NORMAL    0
  200. #define                    T_CLOSED_NORMAL 1
  201. #define                    T_OPEN_INTERP    2
  202. #define                    T_CLOSED_INTERP 3
  203.     int            style;
  204.     int            thickness;
  205.     Color        color;
  206.     int            depth;
  207.     float        style_val;
  208.     int            pen;
  209.     int            fill_style;
  210.     struct f_arrow *for_arrow;
  211.     struct f_arrow *back_arrow;
  212.     /*
  213.      * For T_OPEN_NORMAL and T_CLOSED_NORMAL points are control points while
  214.      * they are knots for T_OPEN_INTERP and T_CLOSED_INTERP whose control
  215.      * points are stored in controls.
  216.      */
  217.     struct f_point *points;
  218.     struct f_control *controls;
  219.     struct f_spline *next;
  220. }
  221.         F_spline;
  222.  
  223. typedef struct f_compound {
  224.     int            tagged;
  225.     struct f_pos    nwcorner;
  226.     struct f_pos    secorner;
  227.     struct f_line  *lines;
  228.     struct f_ellipse *ellipses;
  229.     struct f_spline *splines;
  230.     struct f_text  *texts;
  231.     struct f_arc   *arcs;
  232.     struct f_compound *compounds;
  233.     struct f_compound *next;
  234. }
  235.         F_compound;
  236.  
  237. typedef struct f_linkinfo {
  238.     struct f_line  *line;
  239.     struct f_point *endpt;
  240.     struct f_point *prevpt;
  241.     int            two_pts;
  242.     struct f_linkinfo *next;
  243. }
  244.         F_linkinfo;
  245.  
  246. #define        ARROW_SIZE        sizeof(struct f_arrow)
  247. #define        POINT_SIZE        sizeof(struct f_point)
  248. #define        CONTROL_SIZE        sizeof(struct f_control)
  249. #define        ELLOBJ_SIZE        sizeof(struct f_ellipse)
  250. #define        ARCOBJ_SIZE        sizeof(struct f_arc)
  251. #define        LINOBJ_SIZE        sizeof(struct f_line)
  252. #define        TEXOBJ_SIZE        sizeof(struct f_text)
  253. #define        SPLOBJ_SIZE        sizeof(struct f_spline)
  254. #define        COMOBJ_SIZE        sizeof(struct f_compound)
  255. #define        EPS_SIZE        sizeof(struct f_eps)
  256. #define        LINKINFO_SIZE        sizeof(struct f_linkinfo)
  257.  
  258. /**********************     object codes  **********************/
  259.  
  260. #define        O_ELLIPSE        1
  261. #define        O_POLYLINE        2
  262. #define        O_SPLINE        3
  263. #define        O_TEXT            4
  264. #define        O_ARC            5
  265. #define        O_COMPOUND        6
  266. #define        O_END_COMPOUND        -O_COMPOUND
  267. #define        O_ALL_OBJECT        99
  268.  
  269. /*********************    object masks  ************************/
  270.  
  271. #define M_NONE            0x000
  272. #define M_POLYLINE_POLYGON    0x001
  273. #define M_POLYLINE_LINE        0x002
  274. #define M_POLYLINE_BOX        0x004    /* includes ARCBOX */
  275. #define M_SPLINE_O_NORMAL    0x008
  276. #define M_SPLINE_C_NORMAL    0x010
  277. #define M_SPLINE_O_INTERP    0x020
  278. #define M_SPLINE_C_INTERP    0x040
  279. #define M_TEXT_NORMAL        0x080
  280. #define M_TEXT_HIDDEN        0x100
  281. #define M_ARC            0x200
  282. #define M_ELLIPSE        0x400
  283. #define M_COMPOUND        0x800
  284.  
  285. #define M_TEXT        (M_TEXT_HIDDEN | M_TEXT_NORMAL)
  286. #define M_SPLINE_O    (M_SPLINE_O_NORMAL | M_SPLINE_O_INTERP)
  287. #define M_SPLINE_C    (M_SPLINE_C_NORMAL | M_SPLINE_C_INTERP)
  288. #define M_SPLINE_NORMAL (M_SPLINE_O_NORMAL | M_SPLINE_C_NORMAL)
  289. #define M_SPLINE_INTERP (M_SPLINE_O_INTERP | M_SPLINE_C_INTERP)
  290. #define M_SPLINE    (M_SPLINE_NORMAL | M_SPLINE_INTERP)
  291. #define M_POLYLINE    (M_POLYLINE_LINE | M_POLYLINE_POLYGON | M_POLYLINE_BOX)
  292. #define M_VARPTS_OBJECT (M_POLYLINE_LINE | M_POLYLINE_POLYGON | M_SPLINE)
  293. #define M_OPEN_OBJECT    (M_POLYLINE_LINE | M_SPLINE_O | M_ARC)
  294. #define M_ROTATE_ANGLE    (M_VARPTS_OBJECT | M_ARC | M_TEXT | M_COMPOUND)
  295. #define M_OBJECT    (M_ELLIPSE | M_POLYLINE | M_SPLINE | M_TEXT | M_ARC)
  296. #define M_NO_TEXT    (M_ELLIPSE | M_POLYLINE | M_SPLINE | M_COMPOUND | M_ARC)
  297. #define M_ALL        (M_OBJECT | M_COMPOUND)
  298.